package com.zhiyou100.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zhiyou100.model.MUser;
import com.zhiyou100.service.MLoginService;
import com.zhiyou100.util.BackgroundLogAnno;

@Controller
public class MLoginController {

	@Autowired
	private MLoginService mService;
	
	@RequestMapping("/mlogin")
	public  String MLogin () {
		System.out.println("进入后台登录,跳转到后台登录页面");
		return "forward:/admin/adminlogin.jsp";
	}
	
	@BackgroundLogAnno("后台用户登录")
	@RequestMapping("/mindex")
	public String Mindex(String mName,String mPassword,HttpServletRequest request) {
		System.out.println("进入到后台首页的controller");
		MUser mUser = mService.login(mName,mPassword);
		request.getSession().setAttribute("mUser", mUser);
		System.out.println("查到的后台用户:"+mUser);
		if(mUser!=null) {
			return "forward:/admin/index.jsp";
		}
		return "forward:/admin/adminlogin.jsp";  
	}
	
	
}
